package com.作业.Day16;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test4 {
    public static void main(String[] args) {
        Map <String,String>hashMap = new HashMap<>();
        try (BufferedReader bf = new BufferedReader(new FileReader("user.properties"));
        ) {

              String s1;
              CharSequence c="wangcai";
              while((s1=bf.readLine())!=null) {
                  String[] split = s1.split("=");
                  if (split[0].equals("wangcai")) {
                      split[1] = "88";
                      hashMap.put(split[0], split[1]);
                  } else
                      hashMap.put(split[0], split[1]);

              }

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        try (BufferedWriter bw = new BufferedWriter(new FileWriter("user.properties"))) {
            for (String o : hashMap.keySet()) {
                bw.write(o+"="+hashMap.get(o));
                bw.newLine();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
